<!--
 * @Description: 资源配置
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2021-09-27 11:51:46
 * @LastEditTime: 2021-10-26 11:19:13
 * @FilePath: \cscec-pms-admin\src\views\project\projectDynamicInformation\components\ResourceAllocation.vue
-->
<template>
  <div>
    <a-spin :spinning="loading">
      <title-name title="领导班子" />
      <custom-form ref="form" :is-validate="true" :edit-model="''" :form="form" :form-list="formOption" />
      <a-table
        :columns="columns1"
        :data-source="data1"
        row-key="id"
        bordered
        :pagination="false"
        style="margin-top: 20px"
      />
      <a-table
        :columns="columns2"
        :data-source="data2"
        row-key="id"
        bordered
        :pagination="false"
        style="margin: 40px 0"
      />
      <title-name title="一般管理人员" />
      <a-table
        :columns="columns3"
        :data-source="data3"
        row-key="id"
        bordered
        :pagination="false"
        style="margin-top: 40px"
      />
    </a-spin>
  </div>
</template>
<script>
import { columns1, columns2, columns3 } from '../model.js'
import projectDynamicInformation from '@/api/projectDynamicInformation'
export default {
  name: 'ResourceAllocation',
  components: {},
  props: ['projectId'],
  data() {
    return {
      // 表单
      form: {},
      // 数据加载
      loading: true,
      // 表格
      columns1,
      data1: [],
      columns2,
      data2: [],
      columns3,
      data3: []
    }
  },
  watch: {
    projectId: {
      handler(val) {
        val && this.getDetail(val)
      },
      immediate: true
    }
  },
  computed: {
    // 表单配置
    formOption() {
      return [
        {
          label: '目前项目管理人员数量(编制)',
          keyName: 'authorized',
          type: 'BaseInput',
          disabled: true
        },
        {
          label: '目前项目管理人员数量(含派遣)',
          keyName: 'dispatch',
          type: 'BaseInput',
          disabled: true
        },
        {
          label: '目前项目管理人员数量(含聘用)',
          keyName: 'hire',
          type: 'BaseInput',
          disabled: true
        }
      ]
    }
  },
  mounted() {
  },
  methods: {
    getDetail(val) {
      projectDynamicInformation
        .resource({
          projectId: val
        })
        .then((res) => {
          const { authorized, dispatch, hire, projectManagerList, workYearsList, generalManagerList } = res.data
          this.form = {
            authorized,
            dispatch,
            hire
          }
          this.data1 = projectManagerList
          this.data2 = workYearsList
          this.data3 = generalManagerList
        })
        .finally(() => {
          this.loading = false
        })
    }
  }
}
</script>
<style lang="less" scoped>
</style>

